﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace InputAndOutput
{
    class TestInputAndOutput
    {
        public static List<Student> GetStudents()
        {
            List<Student> students = new List<Student>();
            students.Add(new Student("Pesho", "Kelesho", 1212));
            students.Add(new Student("Stefan", "Conev", 1213));
            students.Add(new Student("Hristo", "Stoichev", 1214));

            return students;
        }

        public static BinaryWriter AddStudent(BinaryWriter binaryWriter, List<Student> students)
        {

            using (binaryWriter)
            {
                for (int i = 0; i < students.Count; i++)
                {
                    
                    binaryWriter.Write(students[i].FirstName + ";" + students[i].LastName + ";");
                    binaryWriter.Write(students[i].FacultyNumber);
                }
            }

            return binaryWriter;
        }

        static void Main(string[] args)
        {
            List<Student> students = GetStudents();

            string fileName = @"../../binary.bin";
            FileStream fileStream = new FileStream(fileName,FileMode.OpenOrCreate);

            BinaryWriter binaryWriter = new BinaryWriter(fileStream);
            AddStudent(binaryWriter, students);
            
            
        }
    }
}
